let main_box = document.querySelector("#main_box ul");
let pinglun = document.querySelector(".pinglun")

// let url = decodeURI(location.href);
// console.log(url);
let url = decodeURI(location.href).split("?")[1].split("=")[1];
console.log(url);

const xhr1 = new XMLHttpRequest();
xhr1.open("get","http://chst.vip:1234/api/getmoneyctrlproduct?productid="+url,true);
xhr1.onload = function(){
    if(xhr1.status === 200){
        let res1 = JSON.parse(xhr1.responseText);
        // console.log(res1);
        console.log(res1.result);

        let main_boxs = "";
        
        

        let regExp = /(?<=imgurl=)[^'"]*/;

        res1.result.forEach(item => {
            let imgsrc = item.productImg2.match(regExp)[0];
            main_boxs += `<li>
                            <div class="title">
                                <h4>${item.productName}</h4>
                            </div>
                            <div class="from">
                                <span>
                                    ${item.productFrom}|${item.productTime}
                                </span>
                                <span>
                                    ${item.productTips}
                                </span>
                            </div>
                            <div class="datail">
                                <p>
                                    <img src="${imgsrc}" alt="">
                                    ${item.productInfo2}
                                </p>
                            </div>
                            <div class="img">
                                <img src="${imgsrc}" alt="">
                            </div>
                            <div class="city">
                                ${item.productCity}
                            </div>
                        </li>`

                       
        });
        main_box.innerHTML = main_boxs;
        pinglun.innerHTML = res1.result[0].productComment;
        
    }
}
xhr1.send(null);
